package string;

/**
 * char charAt(int index)
 * 返回当前字符串中指定位置的字符
 */
public class CharAtDemo {
    public static void main(String[] args) {
        //            0123456789012345
        String str = "thinking in java";
        //查看第10个字符是什么?
        char c = str.charAt(9);
        System.out.println(c);


        //验证回文
        String line = "上海自来水自来海上";
        //i的取值范围:0 1 2 3
        for(int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.print("不");
                break;
            }
        }
        System.out.println("是回文!");



    }
}
